Generated by Cython 3.0.2

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: pearson_correlation.c

+01: # cython: infer_types=True, wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3, profile=True, autogen_pxd=True
  __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 02: 
 03: from libc.math cimport fabs
 04: 
+05: import numpy as np
  __pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_7) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 06: cimport numpy as np
 07: from cython.parallel import prange
 08: 
 09: 
+10: def calculate_ppmcc(np.ndarray im1, np.ndarray im2, int shift_x, int shift_y):
/* Python wrapper */
static PyObject *__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_1calculate_ppmcc(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_7nanopyx_4core_8analysis_19pearson_correlation_calculate_ppmcc, "\n    Calculates the Pearson's correlation between two images after applying a shift.\n    :param im1: numpy array with shape (y, x)\n    :param im2: numpy array with shape (y, x)\n    :param shift_x: int; value to shift images in x dimension\n    :param shift_y: int; value to shift images in y dimension\n    :return: float; value of Pearson's Correlation function after shifting the two images.\n    ");
static PyMethodDef __pyx_mdef_7nanopyx_4core_8analysis_19pearson_correlation_1calculate_ppmcc = {"calculate_ppmcc", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_1calculate_ppmcc, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7nanopyx_4core_8analysis_19pearson_correlation_calculate_ppmcc};
static PyObject *__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_1calculate_ppmcc(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyArrayObject *__pyx_v_im1 = 0;
  PyArrayObject *__pyx_v_im2 = 0;
  int __pyx_v_shift_x;
  int __pyx_v_shift_y;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calculate_ppmcc (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args);
  if (unlikely((__pyx_nargs < 0))) __PYX_ERR(0, 10, __pyx_L3_error)
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_im1,&__pyx_n_s_im2,&__pyx_n_s_shift_x,&__pyx_n_s_shift_y,0};
  PyObject* values[4] = {0,0,0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_im1)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_im2)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("calculate_ppmcc", 1, 4, 4, 1); __PYX_ERR(0, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shift_x)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("calculate_ppmcc", 1, 4, 4, 2); __PYX_ERR(0, 10, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shift_y)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("calculate_ppmcc", 1, 4, 4, 3); __PYX_ERR(0, 10, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "calculate_ppmcc") < 0)) __PYX_ERR(0, 10, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
      values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
      values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
    }
    __pyx_v_im1 = ((PyArrayObject *)values[0]);
    __pyx_v_im2 = ((PyArrayObject *)values[1]);
    __pyx_v_shift_x = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_shift_x == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
    __pyx_v_shift_y = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_shift_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("calculate_ppmcc", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 10, __pyx_L3_error)
  goto __pyx_L3_error;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation.calculate_ppmcc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_im1), __pyx_ptype_5numpy_ndarray, 1, "im1", 0))) __PYX_ERR(0, 10, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_im2), __pyx_ptype_5numpy_ndarray, 1, "im2", 0))) __PYX_ERR(0, 10, __pyx_L1_error)
  __pyx_r = __pyx_pf_7nanopyx_4core_8analysis_19pearson_correlation_calculate_ppmcc(__pyx_self, __pyx_v_im1, __pyx_v_im2, __pyx_v_shift_x, __pyx_v_shift_y);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7nanopyx_4core_8analysis_19pearson_correlation_calculate_ppmcc(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_im1, PyArrayObject *__pyx_v_im2, int __pyx_v_shift_x, int __pyx_v_shift_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__11)
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calculate_ppmcc", 0);
  __Pyx_TraceCall("calculate_ppmcc", __pyx_f[0], 10, 0, __PYX_ERR(0, 10, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation.calculate_ppmcc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__24 = PyTuple_Pack(4, __pyx_n_s_im1, __pyx_n_s_im2, __pyx_n_s_shift_x, __pyx_n_s_shift_y); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
/* … */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7nanopyx_4core_8analysis_19pearson_correlation_1calculate_ppmcc, 0, __pyx_n_s_calculate_ppmcc, NULL, __pyx_n_s_nanopyx_core_analysis_pearson_co, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_calculate_ppmcc, __pyx_t_7) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_nanopyx_core_analysis_pearso, __pyx_n_s_calculate_ppmcc, 10, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 10, __pyx_L1_error)
 11:     """
 12:     Calculates the Pearson's correlation between two images after applying a shift.
 13:     :param im1: numpy array with shape (y, x)
 14:     :param im2: numpy array with shape (y, x)
 15:     :param shift_x: int; value to shift images in x dimension
 16:     :param shift_y: int; value to shift images in y dimension
 17:     :return: float; value of Pearson's Correlation function after shifting the two images.
 18:     """
+19:     return _calculate_ppmcc(im1.astype(np.float32), im2.astype(np.float32), shift_x, shift_y)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_im1), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_im2), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __pyx_f_7nanopyx_4core_8analysis_19pearson_correlation__calculate_ppmcc(__pyx_t_6, __pyx_t_7, __pyx_v_shift_x, __pyx_v_shift_y); if (unlikely(__pyx_t_8 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 19, __pyx_L1_error)
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 20: 
 21: 
+22: cdef float _calculate_ppmcc(float[:, :] im1, float[:, :] im2, int shift_x, int shift_y) nogil:
static float __pyx_f_7nanopyx_4core_8analysis_19pearson_correlation__calculate_ppmcc(__Pyx_memviewslice __pyx_v_im1, __Pyx_memviewslice __pyx_v_im2, int __pyx_v_shift_x, int __pyx_v_shift_y) {
  int __pyx_v_w;
  int __pyx_v_h;
  int __pyx_v_new_w;
  int __pyx_v_new_h;
  int __pyx_v_x0;
  int __pyx_v_y0;
  int __pyx_v_x1;
  int __pyx_v_y1;
  float __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_ppmcc", 1);
  __Pyx_TraceCall("_calculate_ppmcc", __pyx_f[0], 22, 1, __PYX_ERR(0, 22, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  #ifdef WITH_THREAD
  __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation._calculate_ppmcc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  __Pyx_RefNannyFinishContextNogil()
  return __pyx_r;
}
+23:     cdef int w = im1.shape[1]
  __pyx_v_w = (__pyx_v_im1.shape[1]);
+24:     cdef int h = im1.shape[0]
  __pyx_v_h = (__pyx_v_im1.shape[0]);
+25:     cdef int new_w = int(w - fabs(shift_x))
  __pyx_v_new_w = ((int)(__pyx_v_w - fabs(__pyx_v_shift_x)));
+26:     cdef int new_h = int(h - fabs(shift_y))
  __pyx_v_new_h = ((int)(__pyx_v_h - fabs(__pyx_v_shift_y)));
 27: 
+28:     cdef int x0 = max(0, -shift_x)
  __pyx_t_1 = (-__pyx_v_shift_x);
  __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_1 > __pyx_t_2);
  if (__pyx_t_4) {
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  __pyx_v_x0 = __pyx_t_3;
+29:     cdef int y0 = max(0, -shift_y)
  __pyx_t_1 = (-__pyx_v_shift_y);
  __pyx_t_3 = 0;
  __pyx_t_4 = (__pyx_t_1 > __pyx_t_3);
  if (__pyx_t_4) {
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  __pyx_v_y0 = __pyx_t_2;
+30:     cdef int x1 = x0 + shift_x
  __pyx_v_x1 = (__pyx_v_x0 + __pyx_v_shift_x);
+31:     cdef int y1 = y0 + shift_y
  __pyx_v_y1 = (__pyx_v_y0 + __pyx_v_shift_y);
 32: 
+33:     return _pearson_correlation(im1[y0:y0+new_h, x0:x0+new_w], im2[y1:y1+new_h, x1:x1+new_w])
  __pyx_t_5.data = __pyx_v_im1.data;
  __pyx_t_5.memview = __pyx_v_im1.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_5, 0);
  __pyx_t_1 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_5,
    __pyx_v_im1.shape[0], __pyx_v_im1.strides[0], __pyx_v_im1.suboffsets[0],
    0,
    0,
    &__pyx_t_1,
    __pyx_v_y0,
    (__pyx_v_y0 + __pyx_v_new_h),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 33, __pyx_L1_error)
}

if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_5,
    __pyx_v_im1.shape[1], __pyx_v_im1.strides[1], __pyx_v_im1.suboffsets[1],
    1,
    1,
    &__pyx_t_1,
    __pyx_v_x0,
    (__pyx_v_x0 + __pyx_v_new_w),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 33, __pyx_L1_error)
}

__pyx_t_6.data = __pyx_v_im2.data;
  __pyx_t_6.memview = __pyx_v_im2.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
  __pyx_t_1 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_im2.shape[0], __pyx_v_im2.strides[0], __pyx_v_im2.suboffsets[0],
    0,
    0,
    &__pyx_t_1,
    __pyx_v_y1,
    (__pyx_v_y1 + __pyx_v_new_h),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 33, __pyx_L1_error)
}

if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_im2.shape[1], __pyx_v_im2.strides[1], __pyx_v_im2.suboffsets[1],
    1,
    1,
    &__pyx_t_1,
    __pyx_v_x1,
    (__pyx_v_x1 + __pyx_v_new_w),
    0,
    1,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 33, __pyx_L1_error)
}

__pyx_t_7 = __pyx_f_7nanopyx_4core_8analysis_19pearson_correlation__pearson_correlation(__pyx_t_5, __pyx_t_6); if (unlikely(__pyx_t_7 == ((float)-1) && __Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 33, __pyx_L1_error)
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_5, 0);
  __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 0);
  __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
  __pyx_r = __pyx_t_7;
  goto __pyx_L0;
 34: 
 35: 
+36: def pearson_correlation(np.ndarray im1, np.ndarray im2):
/* Python wrapper */
static PyObject *__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_3pearson_correlation(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_7nanopyx_4core_8analysis_19pearson_correlation_2pearson_correlation, "\n    Calculates the Pearson's correlation between two images.\n    :param im1: numpy array with shape (y, x)\n    :param im2: numpy array with shape (y, x)\n    :return: float; value of Pearson's correlation between two images\n    ");
static PyMethodDef __pyx_mdef_7nanopyx_4core_8analysis_19pearson_correlation_3pearson_correlation = {"pearson_correlation", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_3pearson_correlation, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7nanopyx_4core_8analysis_19pearson_correlation_2pearson_correlation};
static PyObject *__pyx_pw_7nanopyx_4core_8analysis_19pearson_correlation_3pearson_correlation(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyArrayObject *__pyx_v_im1 = 0;
  PyArrayObject *__pyx_v_im2 = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pearson_correlation (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args);
  if (unlikely((__pyx_nargs < 0))) __PYX_ERR(0, 36, __pyx_L3_error)
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_im1,&__pyx_n_s_im2,0};
  PyObject* values[2] = {0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_im1)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_im2)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("pearson_correlation", 1, 2, 2, 1); __PYX_ERR(0, 36, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "pearson_correlation") < 0)) __PYX_ERR(0, 36, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
    }
    __pyx_v_im1 = ((PyArrayObject *)values[0]);
    __pyx_v_im2 = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pearson_correlation", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 36, __pyx_L3_error)
  goto __pyx_L3_error;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation.pearson_correlation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_im1), __pyx_ptype_5numpy_ndarray, 1, "im1", 0))) __PYX_ERR(0, 36, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_im2), __pyx_ptype_5numpy_ndarray, 1, "im2", 0))) __PYX_ERR(0, 36, __pyx_L1_error)
  __pyx_r = __pyx_pf_7nanopyx_4core_8analysis_19pearson_correlation_2pearson_correlation(__pyx_self, __pyx_v_im1, __pyx_v_im2);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7nanopyx_4core_8analysis_19pearson_correlation_2pearson_correlation(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_im1, PyArrayObject *__pyx_v_im2) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__12)
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pearson_correlation", 0);
  __Pyx_TraceCall("pearson_correlation", __pyx_f[0], 36, 0, __PYX_ERR(0, 36, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation.pearson_correlation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__25 = PyTuple_Pack(2, __pyx_n_s_im1, __pyx_n_s_im2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
/* … */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7nanopyx_4core_8analysis_19pearson_correlation_3pearson_correlation, 0, __pyx_n_s_pearson_correlation, NULL, __pyx_n_s_nanopyx_core_analysis_pearson_co, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pearson_correlation, __pyx_t_7) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 37:     """
 38:     Calculates the Pearson's correlation between two images.
 39:     :param im1: numpy array with shape (y, x)
 40:     :param im2: numpy array with shape (y, x)
 41:     :return: float; value of Pearson's correlation between two images
 42:     """
+43:     return _pearson_correlation(im1.astype(np.float32), im2.astype(np.float32))
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_im1), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_im2), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __pyx_f_7nanopyx_4core_8analysis_19pearson_correlation__pearson_correlation(__pyx_t_6, __pyx_t_7); if (unlikely(__pyx_t_8 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 44: 
 45: 
+46: cdef float _pearson_correlation(float[:,:] im1, float[:,:] im2) nogil:
static float __pyx_f_7nanopyx_4core_8analysis_19pearson_correlation__pearson_correlation(__Pyx_memviewslice __pyx_v_im1, __Pyx_memviewslice __pyx_v_im2) {
  int __pyx_v_w;
  int __pyx_v_h;
  int __pyx_v_wh;
  float __pyx_v_mean_im1;
  float __pyx_v_mean_im2;
  float __pyx_v_sum_im12;
  float __pyx_v_sum_im11;
  float __pyx_v_sum_im22;
  int __pyx_v_i;
  int __pyx_v_j;
  float __pyx_v_d_im1;
  float __pyx_v_d_im2;
  float __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_pearson_correlation", 1);
  __Pyx_TraceCall("_pearson_correlation", __pyx_f[0], 46, 1, __PYX_ERR(0, 46, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  #ifdef WITH_THREAD
  __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_AddTraceback("nanopyx.core.analysis.pearson_correlation._pearson_correlation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  __Pyx_RefNannyFinishContextNogil()
  return __pyx_r;
}
 47: 
+48:     cdef int w = im1.shape[1]
  __pyx_v_w = (__pyx_v_im1.shape[1]);
+49:     cdef int h = im1.shape[0]
  __pyx_v_h = (__pyx_v_im1.shape[0]);
+50:     cdef int wh = w*h
  __pyx_v_wh = (__pyx_v_w * __pyx_v_h);
 51: 
+52:     cdef float mean_im1 = 0.0
  __pyx_v_mean_im1 = 0.0;
+53:     cdef float mean_im2 = 0.0
  __pyx_v_mean_im2 = 0.0;
+54:     cdef float sum_im12 = 0.0
  __pyx_v_sum_im12 = 0.0;
+55:     cdef float sum_im11 = 0.0
  __pyx_v_sum_im11 = 0.0;
+56:     cdef float sum_im22 = 0.0
  __pyx_v_sum_im22 = 0.0;
 57: 
 58:     cdef int i, j
 59:     cdef float d_im1, d_im2
 60: 
+61:     for j in prange(h):
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      _save = NULL;
      if (PyGILState_Check()) {
        Py_UNBLOCK_THREADS
      }
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
        __pyx_t_1 = __pyx_v_h;
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_3 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) reduction(+:__pyx_v_mean_im1) reduction(+:__pyx_v_mean_im2)
                    #endif /* _OPENMP */
                    for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
                        {
                            __pyx_v_j = (int)(0 + 1 * __pyx_t_2);
                            /* Initialize private variables to invalid values */
                            __pyx_v_i = ((int)0xbad0bad0);
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          if (_save) {
            Py_BLOCK_THREADS
          }
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }
+62:         for i in range(w):
                            __pyx_t_4 = __pyx_v_w;
                            __pyx_t_5 = __pyx_t_4;
                            for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
                              __pyx_v_i = __pyx_t_6;
+63:             mean_im1 += im1[j, i]
                              __pyx_t_7 = __pyx_v_j;
                              __pyx_t_8 = __pyx_v_i;
                              __pyx_v_mean_im1 = (__pyx_v_mean_im1 + (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_im1.data + __pyx_t_7 * __pyx_v_im1.strides[0]) ) + __pyx_t_8 * __pyx_v_im1.strides[1]) ))));
+64:             mean_im2 += im2[j, i]
                              __pyx_t_8 = __pyx_v_j;
                              __pyx_t_7 = __pyx_v_i;
                              __pyx_v_mean_im2 = (__pyx_v_mean_im2 + (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_im2.data + __pyx_t_8 * __pyx_v_im2.strides[0]) ) + __pyx_t_7 * __pyx_v_im2.strides[1]) ))));
                            }
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif
      }
+65:     mean_im1 /= wh
  __pyx_v_mean_im1 = (__pyx_v_mean_im1 / __pyx_v_wh);
+66:     mean_im2 /= wh
  __pyx_v_mean_im2 = (__pyx_v_mean_im2 / __pyx_v_wh);
+67:     for j in prange(h):
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      _save = NULL;
      if (PyGILState_Check()) {
        Py_UNBLOCK_THREADS
      }
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
        __pyx_t_3 = __pyx_v_h;
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_1 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_1 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for lastprivate(__pyx_v_d_im1) lastprivate(__pyx_v_d_im2) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) reduction(+:__pyx_v_sum_im11) reduction(+:__pyx_v_sum_im12) reduction(+:__pyx_v_sum_im22)
                    #endif /* _OPENMP */
                    for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2++){
                        {
                            __pyx_v_j = (int)(0 + 1 * __pyx_t_2);
                            /* Initialize private variables to invalid values */
                            __pyx_v_d_im1 = ((float)__PYX_NAN());
                            __pyx_v_d_im2 = ((float)__PYX_NAN());
                            __pyx_v_i = ((int)0xbad0bad0);
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          if (_save) {
            Py_BLOCK_THREADS
          }
          #endif
          goto __pyx_L16;
        }
        __pyx_L16:;
      }
  }
+68:         for i in range(w):
                            __pyx_t_4 = __pyx_v_w;
                            __pyx_t_5 = __pyx_t_4;
                            for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
                              __pyx_v_i = __pyx_t_6;
+69:             d_im1 = im1[j, i] - mean_im1
                              __pyx_t_7 = __pyx_v_j;
                              __pyx_t_8 = __pyx_v_i;
                              __pyx_v_d_im1 = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_im1.data + __pyx_t_7 * __pyx_v_im1.strides[0]) ) + __pyx_t_8 * __pyx_v_im1.strides[1]) ))) - __pyx_v_mean_im1);
+70:             d_im2 = im2[j, i] - mean_im2
                              __pyx_t_8 = __pyx_v_j;
                              __pyx_t_7 = __pyx_v_i;
                              __pyx_v_d_im2 = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_im2.data + __pyx_t_8 * __pyx_v_im2.strides[0]) ) + __pyx_t_7 * __pyx_v_im2.strides[1]) ))) - __pyx_v_mean_im2);
+71:             sum_im12 += d_im1 * d_im2
                              __pyx_v_sum_im12 = (__pyx_v_sum_im12 + (__pyx_v_d_im1 * __pyx_v_d_im2));
+72:             sum_im11 += d_im1 * d_im1
                              __pyx_v_sum_im11 = (__pyx_v_sum_im11 + (__pyx_v_d_im1 * __pyx_v_d_im1));
+73:             sum_im22 += d_im2 * d_im2
                              __pyx_v_sum_im22 = (__pyx_v_sum_im22 + (__pyx_v_d_im2 * __pyx_v_d_im2));
                            }
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif
      }
+74:     if sum_im11 == 0 or sum_im22 == 0:
  __pyx_t_10 = (__pyx_v_sum_im11 == 0.0);
  if (!__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_10 = (__pyx_v_sum_im22 == 0.0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L26_bool_binop_done:;
  if (__pyx_t_9) {
/* … */
  }
+75:         return 0
    __pyx_r = 0.0;
    goto __pyx_L0;
 76:     else:
+77:         return sum_im12 / (sum_im11 * sum_im22)**0.5
  /*else*/ {
    __pyx_t_11 = __Pyx_SoftComplexToDouble(__Pyx_c_quot_double(__pyx_t_double_complex_from_parts(__pyx_v_sum_im12, 0), __Pyx_c_pow_double(__pyx_t_double_complex_from_parts((__pyx_v_sum_im11 * __pyx_v_sum_im22), 0), __pyx_t_double_complex_from_parts(0.5, 0))), 0); if (unlikely(__pyx_t_11 == ((double)-1) && __Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 77, __pyx_L1_error)
    __pyx_r = __pyx_t_11;
    goto __pyx_L0;
  }